package vg.services.graph_view_manager.realization.graph_view.smart_graph_view.realization;

import vg.services.data_base_manager.data.graph.Vertex;
import vg.services.graph_view_manager.interfaces.graph_view.IGraphAlgorithms;
import vg.services.graph_view_manager.realization.graph_view.smart_graph_view.interfaces.ISGVGraphView4Patching;
import vg.services.graph_view_manager.realization.graph_view.smart_graph_view.interfaces.ISGVPatchManager;
import vg.services.graph_view_manager.realization.graph_view.smart_graph_view.realization.patches.DefaultPatch;

/**
 * Implementation of IGraphAlgorithms.
 * @author Timur Zolotuhin (e-mail: tzolotuhin@gmail.com)
 */
public class SGVGraphAlgorithms implements IGraphAlgorithms {
	// Main components
	private ISGVPatchManager sgv_patch_manager;

	public SGVGraphAlgorithms(ISGVPatchManager sgv_patch_manager) {
		this.sgv_patch_manager = sgv_patch_manager;
	}
	
	@Override
	public void showCriticalPath(final Vertex source, final Vertex target, final boolean maximum, final String attrName) {
		DefaultPatch patch = new DefaultPatch("showCriticalPath") {
			@Override
			public void apply(ISGVGraphView4Patching graphView4patching) {
				graphView4patching.showCriticalPath(source, target, maximum, attrName);
			}
		};
		
		sgv_patch_manager.addPatch(patch);	
	}
	
	@Override
	public void showCycles(final Vertex vertex) {
		DefaultPatch patch = new DefaultPatch("showCycles") {
			@Override
			public void apply(ISGVGraphView4Patching graphView4patching) {
				graphView4patching.showCycles(vertex);
			}
		};
		
		sgv_patch_manager.addPatch(patch);	
	}
	
	@Override
	public void showPaths(final Vertex source, final Vertex target) {
		DefaultPatch patch = new DefaultPatch("showPaths") {
			@Override
			public void apply(ISGVGraphView4Patching graphView4patching) {
				graphView4patching.showPaths(source, target);
			}
		};
		
		sgv_patch_manager.addPatch(patch);		
	}
}
